home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Mania 4
/
MacMania 4.toast
/
/
Demo's
/
Igor Demo Pro
/
1 PutContentsIn Igor Pro Folder
/
WaveMetrics Procedures
/
Analysis
/
Smooth Wave With Blanks
< prev
next >
Wrap
Text File
|
1995-12-31
|
3KB
|
80 lines
#pragma rtGlobals=1
| See the “Sectional Smoothing” example experiment for an example
Function FindSegStart(source, segStart, theEnd) | returns # of first "normal" data point in segment
Wave source | wave being searched
Variable segStart | point to start search from
Variable theEnd | last point to search
| NOTE: if no more normal points in wave, returns neg #
Variable curPoint = segStart
if (curPoint >= theEnd)
return (-1)
endif
do
if (numtype(source[curPoint]) == 0) | is this a normal number
return (curPoint) | we've found segment start
endif
curPoint += 1
while (curPoint < theEnd)
return (-2) | if here, there are no normal points in segment
End
Function FindSegEnd(source, segStart, theEnd) | returns # of last "normal" data point in segment
Wave source | wave being searched
Variable segStart | point to start search from
Variable theEnd | last point to search
Variable curPoint = segStart+1
| NOTE: assumes source[segStart] is normal
if (curPoint > theEnd)
return (theEnd)
endif
do
if (numtype(source[curPoint])) | is this an abnormal number
return (curPoint-1) | we've found segment end
endif
curPoint += 1
while (curPoint <= theEnd)
return (theEnd)
End
Proc SmoothWaveWithBlanks(source, dest, passes)
String source | name of wave to supply data to be smoothed
Prompt source, "Source Wave"
String dest | name of wave to put result in (can be same as source)
Prompt dest, "Dest Wave" | NOTE: dest assumed to have same number of points as source
Variable passes = 5 | number of desired smoothing passes
Prompt passes, "Number of passes: "
Silent 1
Variable lastPoint = numpnts($source)-1
Variable segStart, segEnd | point numbers for segment being worked on
Variable segments=0 | for debugging
segStart = 0;segEnd = 0
do
segStart = FindSegStart($source, segStart, lastPoint) | find start of next segment
Print "segStart = " + num2istr(segStart)
if (segStart < 0)
break | no more normal points
endif
segEnd = FindSegEnd($source, segStart, lastPoint) | find end of next segment
Print "segEnd = " + num2istr(segEnd)
if (segEnd > segStart) | don't smooth one point
Duplicate /O/R=[segStart,segEnd] $source, root:tempSegWave
Smooth passes, root:tempSegWave
$dest[segStart, segEnd] = root:tempSegWave[p-segStart]
segments += 1
endif
segStart = segEnd+1
while (segStart < lastPoint)
Print "Smoothed " + num2istr(segments) + " segments"
KillWaves root:tempSegWave
EndMacro